package com.fqgj.sentry.policy.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.sentry.policy.dao.PcRuleConditionDao;
import com.fqgj.sentry.policy.entity.PcRuleConditionEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: ykpbean
 * Date: 2017-07-29
 * Time: 15:23:32.428
 */

@Repository
public class PcRuleConditionDaoImpl extends AbstractBaseMapper<PcRuleConditionEntity> implements PcRuleConditionDao {

    @Override
    public Integer deleteRuleById(Long ruleId) {
        return getSqlSession().delete(getStatement("deleteRuleById"), ruleId);
    }

    @Override
    public PcRuleConditionEntity selectByRuleId(Long ruleId) {
        return getSqlSession().selectOne(getStatement("selectByRuleId"), ruleId);
    }

    @Override
    public List<PcRuleConditionEntity> findRuleConditionByPolicyId(Long policyId) {
        return getSqlSession().selectList(getStatement("findRuleConditionByPolicyId"), policyId);
    }

    @Override
    public List<PcRuleConditionEntity> findAll() {
        return getSqlSession().selectList(getStatement("findAll"));
    }

    @Override
    public void deleteByRuleIds(List<Long> ruleIds) {
        Map params = new HashMap();
        params.put("ruleIds", ruleIds);
        getSqlSession().selectList(getStatement("deleteByRuleIds"), params);
    }
}